const fontStyleId = "hc-font";
const classNameList = [
    [".hc-max-title","#formTitle",".formTitle",".formTitle .field-item",".el-card__body h2"],//主标题
    [".hc-title"],//标题
    [".hc-min-title",".th-title",".el-submenu__title",".el-menu-item",".el-tree-node__content",".el-breadcrumb",".el-dialog__title",".Typetitle"],//小标题
    [".hc-text",".el-tabs__item",".el-button",".redText",".field-item","el-table__empty-text",".el-tag",".typeLi a",".el-card__body td",".form-label",".el-checkbox__label",".el-tree-node__label",".el-dialog__body",'.right-menu-item .menu-text','.el-submenu__title'],//正文
    [".hc-min-text",".el-textarea__inner",".el-menu span",".el-table__cell",".el-menu-item",".el-breadcrumb",".el-button",".hc-min-title",".hc-text",".el-tabs__item",".el-form-item__label",".el-input__inner",".el-pagination__total",".el-pagination__jump",".el-select-dropdown__item"],//正文小
    [".hc-dec-text"]//描述
]
var fontData

if(window.HC_config.VUE_APP_FONTSIZE){
    fontData = {
        mini: window.HC_config.VUE_APP_FONTSIZE.mini,
        small: window.HC_config.VUE_APP_FONTSIZE.small,
        medium: window.HC_config.VUE_APP_FONTSIZE.medium,
        large: window.HC_config.VUE_APP_FONTSIZE.large,
        biaozhun:window.HC_config.VUE_APP_FONTSIZE.biaozhun || [35, 20, 18, 16, 14, 12],
    }
}else{
    fontData = {
        mini: [30, 18, 16, 14, 12, 10],
        small: [35, 20, 18, 16, 14, 12],
        medium: [40, 22, 20, 18, 16, 14],
        large: [45, 24, 22, 20, 18, 16],
        biaozhun:[35, 20, 18, 16, 14, 12]
    }
}

export function changeFontStyle(P_SIZE)
{
    let fontStyleDom = document.getElementById(fontStyleId);
    if (!fontStyleDom)
    {
        fontStyleDom = document.createElement('style');
        fontStyleDom.type = 'text/css';
        fontStyleDom.id = fontStyleId
        document.getElementsByTagName('HEAD').item(0).appendChild(fontStyleDom);
    }
    fontStyleDom.innerHTML = getStyleHtml(P_SIZE);
}
export function cleanFontStyle()
{
    let fontStyleDom = document.getElementById(fontStyleId)
    if(fontStyleDom)
    {
        fontStyleDom.innerHTML = '';
    }
}

function getStyleHtml(P_SIZE)
{
    let valueToReturn = "";
    classNameList.forEach((pre_className, index) =>
    {
        pre_className.map(item=>{
            valueToReturn += item + "{ font-size:" + fontData[P_SIZE][index] + "px !important;}"
        })
    })
    return valueToReturn;
}